package cn.jkm.api.klm.app.service.content.formula;

import cn.jkm.api.core.helper.ApiResponse;
import cn.jkm.api.klm.app.service.AbstractAppService;
import cn.jkm.core.domain.mongo.content.ContentFormula;
import cn.jkm.framework.core.validator.NotNull;
import cn.jkm.service.content.FormulaService;
import cn.jkm.service.core.domain.ListResult;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @author zhong
 * @version V1.0
 * @project jkm-root
 * @package cn.jkm.api.klm.app.service.content.formula
 * @description //todo
 * @update 2017/7/27 14:50
 */
@Component("formulaList1.0")
@NotNull(name = {"limit","page"}, message = "缺少参数")
public class FormulaList extends AbstractAppService{

    @Reference(version = "1.0")
    FormulaService formulaService;

    @Override
    public Map service(Map request) {

        int limit = Integer.parseInt(request.get("limit").toString());
        int page = Integer.parseInt(request.get("page").toString());
        List<ContentFormula> formulaList =formulaService .formulaListShow(limit,page);
        long count = formulaService .formulaCountShow();
        ListResult<ContentFormula> formulas = new ListResult<>(count,formulaList);
        return ApiResponse.success().body(formulas);
    }
}
